<?php


namespace BoojasrFramework\ServicesContainer\Event;


use BoojasrFramework\Response\Response;
use BoojasrFramework\ServicesContainer\HttpKernelInterface;
use BoojasrFramework\ServicesContainer\Request;

class GetResponseEvent extends KernelEvent
{
    public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType)
    {
        parent::__construct($kernel, $request, $requestType);
    }

    private $response;

    /**
     * Returns the response object.
     *
     * @return Response|null
     */
    public function getResponse()
    {
        return $this->response;
    }

    /**
     * Sets a response and stops event propagation.
     */
    public function setResponse(?Response $response)
    {
        $this->response = $response;

        $this->stopPropagation();
    }

    /**
     * Returns whether a response was set.
     *
     * @return bool Whether a response was set
     */
    public function hasResponse()
    {
        return null !== $this->response;
    }
}
